package com.vf.admin.client.service.impl;

import com.vf.admin.client.dao.MessageChatFromDao;
import com.vf.admin.client.service.MessageChatFromService;
import com.vf.admin.miaodong.entity.MessageChatFrom;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MessageChatFromServiceImpl implements MessageChatFromService {

    @Autowired
    private MessageChatFromDao messageChatFromDao;

    public void add(Integer fromUserId, Integer toUserId) {
        MessageChatFrom messageChatFrom = this.get(fromUserId, toUserId);
        if(messageChatFrom == null) {
            MessageChatFrom params = new MessageChatFrom();
            params.setFromUserId(fromUserId);
            params.setToUserId(toUserId);
            messageChatFromDao.add(params);
        }
    }

    @Override
    public MessageChatFrom get(Integer fromUserId, Integer toUserId) {
        return messageChatFromDao.get(fromUserId, toUserId);
    }

    @Override
    public MessageChatFrom getByFrom(Integer fromUserId, Integer toUserId) {
        return messageChatFromDao.getByFrom(fromUserId, toUserId);
    }

    @Override
    public List<MessageChatFrom> getByUserId(Integer userId) {
        return messageChatFromDao.getByUserId(userId);
    }


}
